﻿@{
    Layout = null;
}

<h2>ManageEmployee</h2>
<link href="~/Content/css/bootstrap.min.css" rel="stylesheet" />
<script src="~/Scripts/js/jquery.min.js"></script>
<script src="~/Scripts/js/bootstrap.min.js"></script>
员工姓名：<input id="EmployeeName" type="text" /><input type="button" value="搜索" onclick="LoadEmployeeInfo(1)" />
<a href="/Employee/AddManageEmployee" style="float:right">注册员工</a>
<table id="t1" class="table-bordered table table-condensed table-responsive">
    <thead>
        <tr>
            <th>编号</th>
            <th>姓名</th>
            <th>年龄</th>
            <th>部门</th>
            <th>职位</th>
            <th>政治面貌</th>
            <th>技术特长</th>
            <th>人员状态</th>
            <th>员工头像</th>
            <th>审核状态</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody></tbody>
</table>
<footer></footer>
<script>
    $(function () {
        LoadEmployeeInfo(1);
    })

    var PageSize = 10;

    //加载员工信息
    function LoadEmployeeInfo(PageIndex) {
        $.ajax({
            type: "post",
            url: "/Employee/EmployeeInfoList2",
            data: { PageIndex: PageIndex, PageSize: PageSize, EmployeeName: $("#EmployeeName").val() },
            success: function (obj) {
                //alert(obj);
                obj = JSON.parse(obj);

                var str = "";
                $("#t1 tbody").empty();
                for (var i = 0; i < obj.list.length; i++) {
                    var PersonState = "";
                    //人员状态
                    if (obj.list[i].PersonState == 0) {
                        PersonState = "在职";
                    }
                    else if (obj.list[i].PersonState == 1) {
                        PersonState = "实习";
                    }
                    else if (obj.list[i].PersonState == 2) {
                        PersonState = "离职";
                    }
                    else {
                        PersonState = "试用";
                    }

                    //信息审核状态
                    var InfoState = "";
                    if (obj.list[i].InfoState == 0) {
                        InfoState = "通过";
                    }
                    else if (obj.list[i].InfoState == 1) {
                        InfoState = "待审核";
                    }
                    else {
                        InfoState = "审核失败";
                    }

                    str += "<tr><td>" + obj.list[i].EmployID + "</td><td>" + obj.list[i].EmployName + "</td><td>" + obj.list[i].Age + "</td><td>" + obj.list[i].DeptName + "</td><td>" + obj.list[i].PositionName + "</td><td>" + obj.list[i].PositionName + "</td><td>" + obj.list[i].Specialty + "</td><td>" + PersonState + "</td><td><img src='" + obj.list[i].EmployeePhoto + "' style='width:80px;height:50px;' /></td><td>" + InfoState + "</td><td><a href='#' onclick='CheckEmpInfoState(" + obj.list[i].EmployID + ")'>信息审核</a>&nbsp;<a href='#' onclick='CheckEmpLoginState(" + obj.list[i].EmployID + "," + obj.list[i].PersonState + ")'>人员管理</a></td></tr>"
                }
                $("#t1 tbody").html(str);
                Pager(obj.Count);
            }
        })
    }

    //分页
    function Pager(count) {
        var pages = Math.ceil(count / PageSize);
        $("footer").empty();
        for (var i = 1; i <= pages; i++) {
            $("footer").append("<a href='#' onclick='LoadEmployeeInfo(" + i + ")'>" + i + "</a>&nbsp;")
        }
    }

    //信息审核
    function CheckEmpInfoState(EmpId) {
        location.href = '/Employee/CheckEmpInfoState?EmpId=' + EmpId + '';
    }

    //人员管理
    function CheckEmpLoginState(EmpId, PersonState) {
        location.href = '/Employee/CheckEmpLoginState?EmpId=' + EmpId + '&PersonState=' + PersonState + '';
    }
</script>